package com.chenchao.javafile;

import java.io.IOException;
import java.io.RandomAccessFile;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/19 18:25
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javafile.Test16.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 随机文件流
 */
public class Test16 {
    public static void main(String[] args) {

        try (RandomAccessFile r = new RandomAccessFile
                ("myjava01/src/com/chenchao/javafile/Test15.java", "r")){
            System.out.println(r.length());
            r.seek(1000);
            byte[] bytes = new byte[100];
            int read = r.read(bytes);
            System.out.println(new String(bytes,0,read));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
